#include <iostream>
using namespace std;

int nums[200005] = {0};
bool cb[200005] = {0};
int n,maxm=0;

int check()
{
    int c1=0,c2=0;
    int b1=0,b2=0;
    for(int i = n-1;i >= 0;i--)
    {
        if(cb[i] == 1)
        {
            if(b1 != nums[i]) b1 = nums[i];
            else
            {
                c1 += b1;
                b1 = 0;
            }
        }
        else
        {
            if(b2 != nums[i]) b2 = nums[i];
            else
            {
                c2 += b2;
                b2 = 0;
            }
        }
    }
    return c1+c2;
}
int DFS(int x)
{
    if(x >= n)
    {
        maxm = max(maxm,check());
        return 0;
    }
    else
    {
        cb[x] = 1;
        DFS(x+1);
        cb[x] = 0;
        DFS(x+1);
        return 0;
    }
}

void setz()
{
    maxm = 0;
    for(int i = 0;i <= 5000;i++)
    {
        nums[i] = 0;
        cb[i] = 0;
    }
}

int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int L;
    cin >> L;
    for(int i = 0;i < L;i++)
    {
        cin >> n;
        for(int i = 0;i < n;i++)
            cin >> nums[i];
        DFS(0);
        cout << maxm << endl;
        setz();
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
